package IO;

import java.io.File;
import java.io.FilenameFilter;

public class CopyFile  {

	/**
	 * @param args
	 */
	public synchronized static void main(String[] args) {
		File src = new File("D:\\abc");
		File file = new File("D:\\a");
		String[] files = file.list(new FilenameFilter() {

			@Override
			public boolean accept(File dir, String name) {
				return new File(dir, name).isFile() && name.endsWith(".java");
			}
		});
		for (String str : files) {
			File file2 = new File(file, str);
			File file3 = new File(file, str.replace(".java", ".txt"));
			file2.renameTo(file3);
			// a
		}

	}
}
